package com.yxy.controller;

import com.yxy.base.BusinessException;
import com.yxy.base.Pagingable;
import com.yxy.base.RestResponse;
import com.yxy.dto.TableReimbursementDetailDto;
import com.yxy.dto.ValidationGroups;
import com.yxy.feign.AuthService;
import com.yxy.model.TableReimbursementDetail;
import com.yxy.utils.TokenCheckUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lixinquan
 * 报销明细信息
 */
@RestController
@Slf4j
@RequestMapping("/tableReimbursementDetail")
public class TableReimbursementDetailController {

  @Autowired
  private TokenCheckUtil tokenCheckUtil;

  @Autowired
  private AuthService authService;
  @Autowired
  private com.yxy.service.TableReimbursementDetailService TableReimbursementDetailService;

  // 获取列表
  @Pagingable
  @PostMapping("/list")
  public RestResponse<List<TableReimbursementDetail>> getList(@RequestBody TableReimbursementDetailDto input) throws BusinessException {
    RestResponse<List<TableReimbursementDetail>> restResponse = new RestResponse<>(200, "成功");
    restResponse.setContent(TableReimbursementDetailService.getlist(input));
    return restResponse;
  }




  @GetMapping("/delete")
  public RestResponse<String> deletebaseuser(String idlist, Integer status) throws BusinessException {
    RestResponse<String> restResponse = new RestResponse<>(200, "成功");
    TableReimbursementDetailService.delete(idlist,status);
    return restResponse;
  }

  //创建与修改
  @PostMapping("/create")
  public RestResponse<TableReimbursementDetail> create(
          @RequestBody @Validated({ValidationGroups.InsertForm.class}) TableReimbursementDetailDto pojo) throws BusinessException {
    RestResponse<TableReimbursementDetail> restResponse = new RestResponse<>(200, "成功");
    restResponse.setContent(TableReimbursementDetailService.save(pojo));
    return restResponse;
  }

  //更新数据
  @PutMapping("/update")
  public RestResponse<TableReimbursementDetail> update(
          @RequestBody @Validated({ValidationGroups.UpdateForm.class}) TableReimbursementDetailDto pojo) throws BusinessException {
    RestResponse<TableReimbursementDetail> restResponse = new RestResponse<>(200, "成功");
    restResponse.setContent(TableReimbursementDetailService.modify(pojo));
    return restResponse;
  }








}
